﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MattDotson.GlobalToolkit
{
    /// <summary>
    /// The default service locator defines the bare minimum that Global Toolkit needs to run. It is highly recommended that
    /// you replace this implementation with your own by either setting GlobalToolkitContext.ServiceLocator or using the 
    /// <see cref="GlobalToolkitConfigurationSection"/> in your application's configuration file.
    /// </summary>
    public sealed class DefaultServiceLocator : IServiceLocator
    {
        private ICurrencyProvider defaultCurrencyProvider = new DefaultCurrencyProvider();

        #region IServiceLocator Members

        /// <summary>
        /// Resolves an instance.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T Resolve<T>()
        {
            if (typeof(T) == typeof(ICurrencyProvider))
            {
                return (T)(object) defaultCurrencyProvider;
            }

            return default(T);
        }

        #endregion
    }
}
